package com.fu.shop.controller;

import com.fu.core.common.JsonResult;
import com.fu.core.pojo.Navigation;
import com.fu.core.pojo.Order;
import com.fu.shop.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author 付龙江
 * @date 2022/1/28 15:46
 */
@RestController
@CrossOrigin
@RequestMapping("/adminIndex")
@Api(tags = "后台首页")
public class IndexController {

    IndexService indexService;

    @Autowired
    public IndexController(IndexService indexService) {
        this.indexService = indexService;
    }

    @ApiOperation(value = "店铺信息、商品信息、交易情况")
    @PostMapping("/indexMessage")
    public Map<String, Object> indexMessage() throws Exception {
        return indexService.indexMessage();
    }

    @ApiOperation(value = "导航信息")
    @PostMapping("/navigationLists")
    public Map<String,Object> navigationLists(){
        List<Navigation> navigationList = new ArrayList<>();
        //首页
        Navigation index = new Navigation(1,"首页","/adminIndex","el-icon-s-home",null);
        navigationList.add(index);
        //店铺管理
        Navigation shop = new Navigation();
        shop.setId(2);
        shop.setName("店铺管理");
        shop.setUrlName("/shop");
        shop.setIconPicture("el-icon-s-shop");
        //店铺管理下面的店铺基本信息、banner
        Navigation shopMessage = new Navigation(3,"店铺基本信息","/shop/shopMessage","el-icon-document",null);
        Navigation shopBanner = new Navigation(4,"店铺banner","/shop/shopBanner","el-icon-picture-outline",null);
        shop.getNavigations().add(shopMessage);
        shop.getNavigations().add(shopBanner);
        navigationList.add(shop);
        //商品管理
        Navigation goods = new Navigation();
        goods.setId(5);
        goods.setName("商品管理");
        goods.setUrlName("/goods");
        goods.setIconPicture("el-icon-s-goods");
        //商品管理下面的类型管理、商品管理
        Navigation goodsType = new Navigation();
        goodsType.setId(6);
        goodsType.setName("类型管理");
        goodsType.setUrlName("/goods/goodsType");
        goodsType.setIconPicture("el-icon-s-help");
        goods.getNavigations().add(goodsType);

        Navigation goodsDetails = new Navigation();
        goodsDetails.setId(7);
        goodsDetails.setName("商品信息");
        goodsDetails.setUrlName("/goods/goodsDetails");
        goodsDetails.setIconPicture("el-icon-goods");
        goods.getNavigations().add(goodsDetails);
        navigationList.add(goods);
        //订单管理
        Navigation orderManager = new Navigation(8,"订单管理","/orderManager","el-icon-s-order",null);
        navigationList.add(orderManager);
        //用户管理
        Navigation userManager = new Navigation(9,"用户管理","/userManager","el-icon-s-custom",null);
        navigationList.add(userManager);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setField("navigation",navigationList);
        return jsonResult.getMap();
    }
}
